<template>
	<view class="flex-col page">
	  <view class="flex-col space-y-452 group_3">
	    <view class="flex-col space-y-20">
	      <view class="flex-col space-y-24 section_3">
	        <view class="flex-row space-x-5 group_4" @click="jumpDetails">
	          <text class="font_2">合同编号：</text>
	          <text class="font_3 text_5">{{info.contractNo || '-'}}</text>
	        </view>
	        <view class="flex-row space-x-8 group_5">
	          <text class="font_2">合同简称：</text>
	          <text class="font_4">{{info.contractShortName || '-'}}</text>
	        </view>
	        <view class="flex-row space-x-8 group_5">
	          <text class="font_2">合同类型：</text>
	          <text class="font_4">{{$commonData.contract[info.formCode] || '-'}}</text>
	        </view>
	        <view class="flex-row space-x-7 group_5">
	          <text class="font_2">签约日期：</text>
	          <text class="font_3 text_6">{{info.signDate || '-'}}</text>
	        </view>
	        <view class="flex-row group_5">
	          <text class="font_2">合作件数：</text>
	          <text @click="jumpOrder(info.contractNo)" class="font_3 text_7">{{info.cooperateCasesNum || '-'}}</text>
	        </view>
	        <view class="flex-row space-x-7 group_5">
	          <text class="font_2">合作款项：</text>
	          <text class="font_5 text_8">{{info.cooperationFund || '-'}}</text>
	        </view>
	        <view class="flex-row space-x-8 group_6">
	          <text class="font_2">已付款项：</text>
	          <text class="font_5 text_9">{{info.payment || '0.00'}}</text>
	        </view>
	      </view>
	      <view class="flex-row justify-between section_4" v-if="isshow && isPdf">
	        <view class="flex-row space-x-20">
	          <image
	            class="image_7"
	            src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/632afc43e391320011695f3b/16647013625105179114.png"
	          />
	          <view class="flex-col items-start space-y-11" @click="downLoadPDF(info.contractFile)">
	            <text class="text_10">{{spliceStr(info.contractFile)}}</text>
	            <!-- <text class="text_11">111kb</text> -->
	          </view>
	        </view>
	        <image
	          class="image_8"
	          src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/632afc43e391320011695f3b/16647013624779989402.png"
	        />
	      </view>
	    </view>
	    <!-- <view class="flex-row justify-center space-x-21 button" v-if="isshow && isPdf" @click="downLoadPDF(info.contractFile)">
	      <image
	        class="image_9"
	        src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/632afc43e391320011695f3b/16647013625200790987.png"
	      />
	      <text class="text_12">下载合同文件</text>
	    </view> -->
	  </view>
	</view>
</template>

<script>
// import details from '../pages/contract/details.vue'
	export default {
		data() {
			return {
				// info:{}
			};
		},
		props:{
			info:{
				type:Object,
				default:()=>{}
			},
			isshow:{
				type:String,
				default:''
			},
			isPdf:{
				type:Boolean,
				default:false
			}
		},
		onLoad(option) {
			
		},
		methods:{
			jumpDetails() {
				let info = JSON.stringify(this.info)
				uni.navigateTo({
					url:`../contract/details?info=${info}`
				})
			},
			jumpOrder(value){
				uni.navigateTo({
					url:`../contract/orderCenter?contractNo=${value}`
				})
			},
			jumpFile(value){
				uni.navigateTo({
					url:`../contract/pdf?contractFile=${value}`
				})
			},
			spliceStr(value) {
				if(!value) return '';
				else {
					let splitKey = value.split('_');
					return splitKey[splitKey.length -1]
				} 
			},
			viewUrl(url){
				wx.downloadFile({
					url:'https://zzn.ahyzg.com/yw6'+url,
					success:function(res) {
						if(res.statusCode == 200) {
							let path = res.tempFilePath;
							wx.openDocument({
								filePath:path,
								success:function(res){
									console.log('-------')
								}
							})
						}
					}
				})
			},
			//下载PDF文件 
			downLoadPDF(url){
			    wx.showModal({
			        title: '温馨提示',
			        content: '确认要打开此PDF文件吗？',
			        showCancel: true,
			        cancelText: '取消',
			        confirmText: '确定',
			        success: (result) => {
			          if (result.confirm) {
			            wx.downloadFile({
			              url: 'https://zzn.ahyzg.com/yw6'+url,    //示例的url地址
			              success: function (resinfo) {
			                  console.log("pdf协议文件已下载")
			                  let path = resinfo.tempFilePath;
			                  console.log(path, resinfo)
			                  wx.openDocument({
			                      filePath: path,
			                      fileType: 'pdf',
			                      success: function (rest) {
			                          console.log('打开文件成功')
			                          console.log(rest);
			                      },
			                      fail: function (error) {
			                          wx.showToast({
			                              icon: 'none',
			                              title: '暂不支持预览，敬请谅解！'
			                          });
			                      },
			                  })
			              },
			              fail: function (err) {
			                  console.log('fail')
			                  console.log(err)
			                  wx.showToast({
			                    icon: 'none',
			                    title: '暂不支持预览，敬请谅解！'
			                });
			              }
			          })     
			          }
			        },
			        fail: () => {},
			        complete: () => {}
			    })
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
	  background-color: #f4f6f8;
	  width: 100%;
	  overflow-y: auto;
	  overflow-x: hidden;
	  height: 100%;
	  .space-y-452 {
	    & > view:not(:first-child),
	    & > text:not(:first-child),
	    & > image:not(:first-child) {
	      margin-top: 452rpx;
	    }
	    .space-y-20 {
	      & > view:not(:first-child),
	      & > text:not(:first-child),
	      & > image:not(:first-child) {
	        margin-top: 20rpx;
	      }
	      .space-y-24 {
	        & > view:not(:first-child),
	        & > text:not(:first-child),
	        & > image:not(:first-child) {
	          margin-top: 24rpx;
	        }
	        .space-x-5 {
	          & > view:not(:first-child),
	          & > text:not(:first-child),
	          & > image:not(:first-child) {
	            margin-left: 5rpx;
	          }
	          .text_5 {
	            margin-top: 6rpx;
	          }
	        }
	        .group_4 {
	          padding: 29rpx 3rpx 18rpx;
	          border-bottom: solid 1rpx #e2e2e2;
	        }
	        .space-x-8 {
	          & > view:not(:first-child),
	          & > text:not(:first-child),
	          & > image:not(:first-child) {
	            margin-left: 8rpx;
	          }
	          .font_4 {
	            font-size: 26rpx;
	            font-family: Microsoft YaHei;
	            line-height: 26rpx;
	            color: #444444;
	          }
	          .text_9 {
	            margin-top: 3rpx;
	          }
	        }
	        .group_5 {
	          padding: 0 3rpx;
	          .text_7 {
	            margin: 3rpx 0 3rpx 7rpx;
	            color: #5372fc;
	            line-height: 20rpx;
	          }
	        }
	        .font_2 {
	          font-size: 26rpx;
	          font-family: Microsoft YaHei;
	          line-height: 26rpx;
	          color: #777777;
	        }
	        .space-x-7 {
	          & > view:not(:first-child),
	          & > text:not(:first-child),
	          & > image:not(:first-child) {
	            margin-left: 7rpx;
	          }
	          .text_6 {
	            margin-top: 3rpx;
	          }
	          .text_8 {
	            margin-top: 3rpx;
	          }
	        }
	        .font_3 {
	          font-size: 26rpx;
	          font-family: Microsoft YaHei;
	          line-height: 21rpx;
	          color: #444444;
	        }
	        .group_6 {
	          padding: 0 5rpx;
	        }
	        .font_5 {
	          font-size: 26rpx;
	          font-family: Microsoft YaHei;
	          line-height: 24rpx;
	          color: #444444;
	        }
	      }
	      .section_3 {
	        padding: 0 22rpx 30rpx 38rpx;
	        background-color: #ffffff;
	      }
	      .section_4 {
	        padding: 30rpx 37rpx 30rpx 43rpx;
	        background-color: #ffffff;
	        .space-x-20 {
	          & > view:not(:first-child),
	          & > text:not(:first-child),
	          & > image:not(:first-child) {
	            margin-left: 20rpx;
	          }
	          .image_7 {
	            width: 48rpx;
	            height: 60rpx;
	          }
	          .space-y-11 {
	            & > view:not(:first-child),
	            & > text:not(:first-child),
	            & > image:not(:first-child) {
	              margin-top: 11rpx;
	            }
	            .text_10 {
	              color: #666666;
	              font-size: 28rpx;
	              font-family: Microsoft YaHei;
	              line-height: 31rpx;
	            }
	            .text_11 {
	              color: #999999;
	              font-size: 20rpx;
	              font-family: Microsoft YaHei;
	              line-height: 16rpx;
	            }
	          }
	        }
	        .image_8 {
	          align-self: center;
	          width: 13rpx;
	          height: 25rpx;
	        }
	      }
	    }
	    .space-x-21 {
	      & > view:not(:first-child),
	      & > text:not(:first-child),
	      & > image:not(:first-child) {
	        margin-left: 21rpx;
	      }
	      .image_9 {
	        margin-left: 173rpx;
	        width: 30rpx;
	        height: 31rpx;
	      }
	      .text_12 {
	        margin-right: 171rpx;
	        color: #ffffff;
	        font-size: 34rpx;
	        font-family: Microsoft YaHei;
	        line-height: 34rpx;
	      }
	    }
	    .button {
	      padding: 28rpx 0 26rpx;
	      align-self: center;
	      background-color: #5677fc;
	      box-shadow: 0px -5rpx 7rpx #00000026;
	      border-radius: 44rpx;
	      width: 600rpx;
	    }
	  }
	  .group_3 {
	    padding: 18rpx 0 2rpx;
	    flex: 1 1 auto;
	    overflow-y: auto;
	  }
	}
</style>